package cn.jiyun.service.impl;

import cn.jiyun.entity.XmBankcard;
import cn.jiyun.entity.XmCouriers;
import cn.jiyun.entity.XmDistributionstations;
import cn.jiyun.mapper.XmBankcardMapper;
import cn.jiyun.mapper.XmCouriersMapper;
import cn.jiyun.mapper.XmDistributionstationsMapper;
import cn.jiyun.service.IXmCouriersService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2024-11-28
 */
@Service
public class XmCouriersServiceImpl extends ServiceImpl<XmCouriersMapper, XmCouriers> implements IXmCouriersService {

    @Autowired
    private XmCouriersMapper xmCouriersMapper;

    @Autowired
    private XmBankcardMapper xmBankcardMapper;
    @Override
    public Page<XmCouriers> findAll(Integer current, Integer pageSize, XmCouriers xmCouriers) {
        Page<XmCouriers> xmCouriersPage = new Page<>(current, pageSize);
        Page<XmCouriers> xmCouriersPage1=xmCouriersMapper.findAll(xmCouriersPage, xmCouriers);
        List<XmCouriers> records = xmCouriersPage1.getRecords();
        for (XmCouriers xmCouriers1 : records) {
            Integer id = xmCouriers1.getId();
            QueryWrapper<XmBankcard> queryWrapper=new QueryWrapper<>();
            queryWrapper.eq("cid",id);
            List<XmBankcard> xmBankcards = xmBankcardMapper.selectList(queryWrapper);
            xmCouriers1.setXmBankcards(xmBankcards);
        }
        return xmCouriersPage1;
    }


    @Override
    public Integer findAllCourier() {
        return xmCouriersMapper.findAllCourier();
    }

    @Override
    public Integer findAllCourier2() {
        return xmCouriersMapper.findAllCourier2();
    }
}
